package structuralModel.bridge.reductionBridge.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import structuralModel.bridge.reductionBridge.SceneConfigEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class EmissionFactorInfoDto {

    private String key;

    private List<SceneConfigEnum> sceneConfigInfoEnumList;

    private ReductionEmissionFactorDto reductionEmissionFactorDto;


    //@Override
    //public boolean equals(Object o) {
    //    if (this == o) {
    //        return true;
    //    }
    //    if (o == null || getClass() != o.getClass()) {
    //        return false;
    //    }
    //    // 最新因子的时候, 校验 TypeName + 因子库名称/id
    //    // 手动选择/自定义输入的时候, 没有因子+ 因子库, 只有自定义输入的姓名
    //
    //    EmissionFactorInfoDto that = (EmissionFactorInfoDto) o;
    //    ReductionEmissionFactorDto rDto = that.getReductionEmissionFactorDto();
    //    String rDtoFactorLibraryId = rDto.getFactorLibraryId();
    //    String rDtoEmissionFactorName = rDto.getEmissionFactorName();
    //    String rDtoEmissionFactorTypeName = rDto.getEmissionFactorTypeName();
    //    BigDecimal rDtoDataValue = rDto.getDataValue();
    //    String rDtoMolecularUnit = rDto.getMolecularUnit();
    //    String rDtoDenominatorUnit = rDto.getDenominatorUnit();
    //
    //    String factorLibraryId = this.getReductionEmissionFactorDto().getFactorLibraryId();
    //    String emissionFactorName = this.getReductionEmissionFactorDto().getEmissionFactorName();
    //    String emissionFactorTypeName = this.getReductionEmissionFactorDto().getEmissionFactorTypeName();
    //    BigDecimal dataValue = this.getReductionEmissionFactorDto().getDataValue();
    //    String molecularUnit = this.getReductionEmissionFactorDto().getMolecularUnit();
    //    String denominatorUnit = this.getReductionEmissionFactorDto().getDenominatorUnit();
    //
    //    // 自定义输入的时候 : 计算因子名称、数值、单位，三者都相同时，去重展示（不同的气体必然计算因子名称不同）
    //    if (!Boolean.parseBoolean(rDto.getEmissionFactorCustomInput())) {
    //        // 考虑分母单位为空的情况时,不参与规则校验
    //        if (StringUtils.isNotEmpty(denominatorUnit) && StringUtils.isNotEmpty(rDtoDenominatorUnit)) {
    //            // 分母单位不为空时, 参与校验
    //            return Objects.equals(emissionFactorName,
    //                    rDtoEmissionFactorName) && Objects.equals(dataValue,
    //                    rDtoDataValue) && Objects.equals(molecularUnit,
    //                    rDtoMolecularUnit) && Objects.equals(denominatorUnit,
    //                    rDtoDenominatorUnit);
    //        } else {
    //            //否则校验到分子单子
    //            //return Objects.equals(emissionFactorName,
    //            //        rDto.getEmissionFactorName()) && Objects.equals(reductionEmissionFactorDto.getDataValue(),
    //            //        rDto.getDataValue()) && Objects.equals(reductionEmissionFactorDto.getMolecularUnit(),
    //            //        rDto.getMolecularUnit());
    //            return Objects.equals(emissionFactorName,
    //                    rDtoEmissionFactorName) && Objects.equals(dataValue,
    //                    rDtoDataValue) && Objects.equals(molecularUnit,
    //                    rDtoMolecularUnit);
    //        }
    //    }else {
    //        // 手动选择时: 计算因子名称、因子库名称/id、类型名称
    //        if (Boolean.parseBoolean(that.getReductionEmissionFactorDto().getEmissionFactorModel())) {
    //            //return Objects.equals(reductionEmissionFactorDto.getFactorLibraryId(),
    //            //        that.getReductionEmissionFactorDto().getFactorLibraryId()) && Objects.equals(reductionEmissionFactorDto.getEmissionFactorName(),
    //            //        that.getReductionEmissionFactorDto().getEmissionFactorName()) && Objects.equals(reductionEmissionFactorDto.getEmissionFactorTypeName(),
    //            //        that.getReductionEmissionFactorDto().getEmissionFactorTypeName());
    //            return Objects.equals(emissionFactorName,
    //                                  rDtoEmissionFactorName) && Objects.equals(factorLibraryId,
    //                                                                            rDtoFactorLibraryId) && Objects.equals(emissionFactorTypeName,
    //                                                                                                                   rDtoEmissionFactorTypeName);
    //        } else {
    //            // 选择碳因子时: 计算因子名称、因子库名称/id
    //            //return Objects.equals(reductionEmissionFactorDto.getFactorLibraryId(),
    //            //        that.getReductionEmissionFactorDto().getFactorLibraryId()) && Objects.equals(reductionEmissionFactorDto.getEmissionFactorName(),
    //            //        that.getReductionEmissionFactorDto().getEmissionFactorName());
    //            return Objects.equals(emissionFactorName,
    //                                  rDtoEmissionFactorName) && Objects.equals(factorLibraryId,
    //                                                                            rDtoFactorLibraryId);
    //        }
    //    }
    //
    //}
    //
    //@Override
    //public int hashCode() {
    //    int result = 17; // 初始化一个非零常数，用于开始散列计算
    //    String factorLibraryId = this.getReductionEmissionFactorDto().getFactorLibraryId();
    //    String emissionFactorName = this.getReductionEmissionFactorDto().getEmissionFactorName();
    //    String emissionFactorModel = this.getReductionEmissionFactorDto().getEmissionFactorModel();
    //    String emissionFactorCustomInput = this.getReductionEmissionFactorDto().getEmissionFactorCustomInput();
    //    String emissionFactorTypeName = this.getReductionEmissionFactorDto().getEmissionFactorTypeName();
    //    BigDecimal dataValue = this.getReductionEmissionFactorDto().getDataValue();
    //    String molecularUnit = this.getReductionEmissionFactorDto().getMolecularUnit();
    //    String denominatorUnit = this.getReductionEmissionFactorDto().getDenominatorUnit();
    //
    //    if (!Boolean.parseBoolean(emissionFactorCustomInput)) {
    //        result = 31 * result + (emissionFactorCustomInput == null ? 0 : emissionFactorCustomInput.hashCode());
    //        result = 31 * result + (emissionFactorName == null ? 0 : emissionFactorName.hashCode());
    //        result = 31 * result + (dataValue == null ? 0 : dataValue.hashCode());
    //        result = 31 * result + (molecularUnit == null ? 0 : molecularUnit.hashCode());
    //        if (StringUtils.isNotEmpty(denominatorUnit)) {
    //            result = 31 * result + (denominatorUnit == null ? 0 : denominatorUnit.hashCode());
    //        }
    //    }else {
    //        if (Boolean.parseBoolean(emissionFactorModel)) {
    //            result = 31 * result + (emissionFactorModel == null ? 0 : emissionFactorModel.hashCode());
    //            result = 31 * result + (factorLibraryId == null ? 0 : factorLibraryId.hashCode());
    //            result = 31 * result + (emissionFactorName == null ? 0 : emissionFactorName.hashCode());
    //            result = 31 * result + (emissionFactorTypeName == null ? 0 : emissionFactorTypeName.hashCode());
    //        } else {
    //            result = 31 * result + (emissionFactorModel == null ? 0 : emissionFactorModel.hashCode());
    //            result = 31 * result + (factorLibraryId == null ? 0 : factorLibraryId.hashCode());
    //            result = 31 * result + (emissionFactorName == null ? 0 : emissionFactorName.hashCode());
    //        }
    //    }
    //
    //    return result;
    //}
}
